package com.estudy.entity;

/**
 * @author: sun.hongliang
 * @create: 2019/09/04 18:55
 */
public enum KnowLedgeEnum {

    NORMAL(0, "一般知识"),

    INDUSTRY(1, "行业知识"),

    PROFESSION(2, "专业知识"),

    ENCYCLOPEDIA(3, "百科知识");

    private int code;
    private String name;

    KnowLedgeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static KnowLedgeEnum getEnumByCode(int code) {
        KnowLedgeEnum[] values = KnowLedgeEnum.values();
        for (KnowLedgeEnum knowLedgeEnum : values) {
            if (knowLedgeEnum.code == code) {
                return knowLedgeEnum;
            }
        }
        return NORMAL;
    }

    @Override
    public String toString() {
        return "KnowLedgeEnum{" +
                "code=" + code +
                ", name='" + name + '\'' +
                '}';
    }
}
